emacs_write: Return size_t, not ssize_t, to avoid overflow issues.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 13 Apr 2011 05:02:54 +0000 (22:02 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 13 Apr 2011 05:02:54 +0000 (22:02 -0700)
commit5b7b82462301f270d3c7c1b9f4593b673569cf9b
treea4e52adff58981dbee683042ebfb66b28a1adc30
parent62ca30617287ed847fefd8b96a910f88307ab6a4
emacs_write: Return size_t, not ssize_t, to avoid overflow issues.

* gnutls.c, gnutls.h (emacs_gnutls_write): Return size_t, not ssize_t.
* sysdep.c, lisp.h (emacs_write): Likewise.
Without the above change, emacs_gnutls_write and emacs_write had
undefined behavior and would typically mistakenly report an error
when writing a buffer whose size exceeds SSIZE_MAX.
(emacs_read, emacs_write): Remove check for negative size, as the
Emacs source code has been audited now.
(emacs_write): Adjust to new signature, making the code look more
like that of emacs_gnutls_write.
* process.c (send_process): Adjust to the new signatures of
emacs_write and emacs_gnutls_write.  Do not attempt to store
a byte offset into an 'int'; it might overflow.
src/ChangeLog
src/gnutls.c
src/gnutls.h
src/lisp.h
src/process.c
src/sysdep.c